package coutom.sink.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.IOException;
import java.io.Serializable;
import java.util.Map;

/**
 * @author : ZhaoY
 * @description :
 * @date : 2021-03-01 10:55
 **/
@Data
@Accessors(chain = true)
public class SinkConfig implements Serializable {
    private static final long serialVersionUID = 1L;
    private String outDirectory;
    private String fileTestSuffix;
    private String fileName;

    /**
     * @param
     * @detail 将连机器yaml配置进行数据绑定
     * @Return
     */
    public static SinkConfig load(Map<String, Object> map) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(new ObjectMapper().writeValueAsString(map), SinkConfig.class);
    }
}
